package com.idealighter.game.server.db.datadb.dao;

import com.google.inject.Inject;
import com.google.inject.Singleton;

import com.idealighter.game.server.db.datadb.generate.domain.RoomCardScoreDomain;
import com.idealighter.game.server.db.datadb.generate.domain.RoomCardScoreDomainExample;
import com.idealighter.game.server.db.datadb.mapper.RoomCardScoreMapper;
import com.idealighter.game.server.db.datadb.mapper.domain.ScoreRangeDomain;

import java.util.Date;
import java.util.List;

@Singleton
public class RoomCardScoreDao {

  private RoomCardScoreMapper mapper;

  @Inject
  public RoomCardScoreDao(RoomCardScoreMapper mapper) {
    this.mapper = mapper;
  }

  public List<Long> selectMyRoomGameRecord(long playerId, Date lastCreateTime, int pageSize) {
    return mapper.selectMyRoomGameRecord(playerId, lastCreateTime, pageSize);
  }

  public List<Long> selectMyGroupGameRecord(long playerId, Date lastCreateTime, int pageSize) {
    return mapper.selectMyGroupGameRecord(playerId, lastCreateTime, pageSize);
  }

  public List<Long> selectMyAllGameRecord(long playerId, Date lastCreateTime, int pageSize) {
    return mapper.selectMyAllGameRecord(playerId, lastCreateTime, pageSize);
  }

  /**
   * 获取战绩列表 .
   *
   * @author abin
   * @date 2018年5月25日 下午4:40:16
   * @param roomId 房间id.
   * @return 战绩列表.
   */
  public List<RoomCardScoreDomain> selectByRoomId(long roomId) {
    RoomCardScoreDomainExample example = new RoomCardScoreDomainExample();
    example.createCriteria().andRoomEqualTo(roomId);

    return mapper.selectByExample(example);
  }

  /**
   * 获取群战绩 .
   *
   * @author abin
   * @date 2018年5月25日 下午5:45:34
   * @param lastPlayerId 最后玩家id.
   * @param createTime 创建时间.
   * @param endTime 结束时间.
   * @param limit limit.
   * @return 战绩列表.
   */
  public List<ScoreRangeDomain> selectScoreRange(Integer groupId, Long lastPlayerId,
      Date createTime, Date endTime, int limit) {
    return mapper.selectScoreRange(groupId, lastPlayerId, createTime, endTime, limit);
  }
}
